*
* $Id$
*
* $Log: cevap.F,v $
* Revision 1.1.1.1  2002/06/16 15:18:43  hristov
* Separate distribution  of Geant3
*
* Revision 1.1.1.1  1999/05/18 15:55:21  fca
* AliRoot sources
*
* Revision 1.1.1.1  1995/10/24 10:21:55  cernlib
* Geant
*
*
#include "geant321/pilot.h"
*CMZ :  3.21/04 23/02/95  14.46.01  by  S.Giani
*-- Author :
      SUBROUTINE CEVAP(E,Q,ATAR,CB,EX)
C       THIS ROUTINE SAMPLES AN EXIT ENERGY FROM AN
C       EVAPORATION SPECTRUM
#include "geant321/minput.inc"
      SAVE
C       CONVERT THE COULOMB BARRIER (CB) TO UNITS OF EV
      CB=CB*1.00E+06
C       CALCULATE THE MAXIMUM ENERGY AVAILABLE
      CBI=CB
      EMAX=E+Q-CB
      IF(EMAX.GT.0.0)GO TO 10
      CB=0.5*CB
      EMAX=E+Q-CB
      IF(EMAX.GT.0.0)GO TO 10
      CB=0.0
      EMAX=E+Q-CB
      IF(EMAX.GT.0.0)GO TO 10
      WRITE(IOUT,10000)E,EMAX,Q,CBI
10000 FORMAT(' MICAP: NEGATIVE MAXIMUM ENERGY CALCULATED IN ROUTINE ',
     1'EVAP --- INDICATING PROBABLE CROSS SECTION ERROR ALLOWING ',
     2'THE REACTION TO OCCUR',/,10X,'E,EMAX,Q,CB=',4E13.5)
      WRITE(6,*) ' CALOR: Fatal ERROR in EVAP ====> STOP '
      STOP
C       CALCULATE THE NUCLEAR TEMPERATURE (THETA)
   10 THETA=4.0161E+03*(SQRT(E+Q-CB)/(ATAR**0.8333333))
C       SELECT THE EXIT ENERGY FROM AN EVAPORATION SPECTRUM
   20 R1=FLTRNF(0)
      R2=FLTRNF(0)
      W=-ALOG(R1*R2)
      EX=THETA*W
      IF(EX.LT.0.0) EX = 0.0
      IF(EX.LE.EMAX)RETURN
C       RESAMPLE 75% OF THE TIME IF EX IS GREATER THAN EMAX
      R=FLTRNF(0)
      IF(R.LE.0.75)GO TO 20
#if defined(CERNLIB_MDEBUG)
      IF(EX.GT.20.*EMAX) WRITE(IOUT,10100)EX,EMAX
10100 FORMAT(' MICAP: WARNING EX > EMAX=',2E13.5,' IN ROUTINE EVAP')
#endif
      EX=EMAX
      RETURN
      END
